layui.use(['table', 'admin', 'ax', 'laytpl','jquery'], function () {
    var $ = layui.$;
    var table = layui.table;
    var $ax = layui.ax;
    var admin = layui.admin;
    var laytpl = layui.laytpl;

     /**
      * 工程流水
      */
     var TaskFlow = {
         tableId: "taskFlowTable"
     };

    /**
     * 初始化表格的列
     */
     TaskFlow.initColumn = function () {
         return [[
             {field: 'name', title: '工程名称',width:210, align: "left",fixed: 'left'},
             // {field: 'process', title: '最新进度',width:210, align: "left", style:'font-size: 13px;'},
             {field: 'taskFlowResultList', align: "left", height: 80, templet: '#statusTpl', title: '工程进度'}
         ]];
     };

    TaskFlow.tabCfg={
        elem: '#' + TaskFlow.tableId,
        data:[],
        page: true,
        even: true,
        cellMinWidth: 100,
        height: "full-59",
        cols: TaskFlow.initColumn(),

        done: function(res, curr, count){
            $(".layui-table-main  tr").each(function (index ,val) {
                $($(".layui-table-fixed .layui-table-body tbody tr")[index]).height($(val).height());
            });

            setTimeout(() => {
                $(".layui-table-cell .line-box").each(function (index ,val) {
                    $($(".layui-table-cell .line-box")[index]).scrollLeft(6000)
                });
            }, 500)
        }
    };
    var  para = sessionStorage.getItem("gcjdList");
    if(para!=null){
        var p=JSON.parse(para);
        TaskFlow.tabCfg.url=Feng.ctxPath + '/project/proTaskFolwList';
        TaskFlow.tabCfg.where=p;
        if(p.name!=''){
            $('#condition').val(p.name);
        }
    }
    // 渲染表格
    var tableResult = table.render(TaskFlow.tabCfg);

    // 搜索按钮点击事件
    $('#btnSearch').click(function () {
        TaskFlow.search();
    });

    /**
     * 点击查询按钮
     */
    TaskFlow.search = function () {
        var queryData = {};
        queryData['name'] = $("#condition").val();
        // table.reload(TaskFlow.tableId, {where: queryData});
        TaskFlow.tabCfg.url=Feng.ctxPath + '/project/proTaskFolwList';
        TaskFlow.tabCfg.where=queryData;
        table.render(TaskFlow.tabCfg);
        sessionStorage.setItem("gcjdList",JSON.stringify(queryData));
    };

    TaskFlow.search();

});
